home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Networking / GetPPPStatus / headers / MoreFinderEvents.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-06  |  11.8 KB  |  295 lines  |  [TEXT/CWIE]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Functions to help you build and sending Apple events to the Finder.
  5. **
  6. **    by Andy Bachorski, Apple Developer Technical Support
  7. **
  8. **    File:        MoreFinderEvents.h
  9. **
  10. **    Version:    0.3.5
  11. **
  12. **    Copyright © 1996 Apple Computer, Inc.
  13. **    All rights reserved.
  14. **
  15. **    You may incorporate this sample code into your applications without
  16. **    restriction, though the sample code has been provided "AS IS" and the
  17. **    responsibility for its operation is 100% yours.  However, what you are
  18. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  19. **    after having made changes. If you're going to re-distribute the source,
  20. **    we require that you make it clear in the source that the code was
  21. **    descended from Apple Sample Code, but that you've made changes.
  22. */
  23.  
  24. #ifndef MOREFINDEREVENTS
  25. #define MOREFINDEREVENTS
  26.  
  27. //    Prefix file
  28. #include "Prefix.h"
  29.  
  30. //    System includes
  31. #include <Aliases.h>
  32. #include <AppleScript.h>
  33. #include <Components.h>
  34. #include <Folders.h>
  35. #include <Icons.h>
  36. #include <OSA.h>
  37.  
  38.  
  39.  
  40. enum {
  41.     kFinderFileType            = 'FNDR',
  42.     kFinderCreatorType        = 'MACS'
  43. };
  44.  
  45.  
  46.  
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50.  
  51. PASCAL OSErr MFESetSelectionToNone( const AEIdleUPP idleProcUPP );
  52. /*
  53.     Sets the Finder's selection to nothing by sending it an empty list.
  54. */
  55.  
  56. // *****************************************************************************
  57.  
  58. PASCAL OSErr MFEChangeFolderViewNewSuite( const FSSpecPtr fssPtr,
  59.                                           const long viewStyle,
  60.                                           const AEIdleUPP idleProcUPP );
  61. /*
  62.     Given an FSSpec to a folder and a view constant value from the view by list
  63.     defined in AERegistry.h, send an Apple event to the system 7.5.x Finder asking
  64.     it to set the view of the folder's window to the specified style.
  65.  
  66.     Requires that the folder's window be open, otherwise an error is returned
  67.     in the reply event.
  68.     
  69.     If your application will receive update event (i.e., it has windows), you must
  70.     supply a more complete idle function than the simple idle function included
  71.     with this library. It should pass any updated, activate, null, or osEvt events
  72.     received to your application's do event routine.
  73. */
  74.  
  75. // *****************************************************************************
  76. PASCAL OSErr MFEChangeFolderViewOldSuite( const FSSpecPtr fssPtr,
  77.                                           const long viewStyle,
  78.                                           const AEIdleUPP idleProcUPP );
  79. /*
  80.     Given an FSSpec to a folder and a view constant value from the view by list
  81.     defined in AERegistry.h, send an Apple event to the system 7.1.1/7.1.2 Finder
  82.     asking it to set the view of the folder's window to the specified style.
  83.     
  84.     If your application will receive update event (i.e., it has windows), you must
  85.     supply a more complete idle function than the simple idle function included
  86.     with this library. It should pass any updated, activate, null, or osEvt events
  87.     received to your application's do event routine.
  88. */
  89.  
  90. // *****************************************************************************
  91.  
  92. PASCAL OSErr MFEChangeFolderView( const FSSpecPtr fssPtr,
  93.                                   const long viewStyle,
  94.                                   const AEIdleUPP idleProcUPP );
  95. /*
  96.     Given an FSSpec to a folder and a view constant value from the view by list
  97.     defined in AERegistry.h, send an Apple event to the Finder asking it to set
  98.     the view of the folder's window to the specified style.
  99.  
  100.     Requires that the folder's window be open, otherwise an error is returned
  101.     in the reply event.
  102.     
  103.     If your application will receive update event (i.e., it has windows), you must
  104.     supply a more complete idle function than the simple idle function included
  105.     with this library. It should pass any updated, activate, null, or osEvt events
  106.     received to your application's do event routine.
  107. */
  108.  
  109. // *****************************************************************************
  110.  
  111. PASCAL OSErr MFEAddCustomIconToItem( const FSSpecPtr fssPtr,
  112.                                      const Handle theIconSuite,
  113.                                      const IconSelectorValue iconSelector,
  114.                                      const AEIdleUPP idleProcUPP );
  115.  
  116. /*    
  117.     MFEAddCustomIconToItem adds a custom icon, via the Finder, to the item 
  118.     specified by the fssPtr. 
  119.     If an UPP to an idle function is provided in the idleProcUPP parameter,
  120.     AESend is called with a send mode of kAEWaitReply. If idleProcUPP is set
  121.     to nil, kAENoReply will be used for the send mode.
  122.  
  123.     fssPtr            input:    The item to add the custom icon to.
  124.     theIconSuite    input:    The handle to the icon suite to install.
  125.     iconSelector    input:    An IconSelectorValue specifying which icon types
  126.                             to add.
  127.     idleProcUPP        input:    A UniversalProcPtr for an idle function, or nil.
  128.     
  129.     Result Codes
  130.     _____________
  131.     noErr                        0        No error    
  132.     paramErr                    -50        The value of target or alias parameter, or of both,
  133.                                         is NIL or odd, or the alias record is corrupt
  134.     eLenErr                        -92        Buffer too big to send    
  135.     memFullErr                    -108    Not enough room in heap zone    
  136.     procNotFound                -600    No eligible process with specified descriptor
  137.     connectionInvalid            -609    Nonexistent signature or session ID    
  138.     noUserInteractionAllowed    -610    Background application sends event
  139.                                         requiring authentication    
  140.     noPortErr                    -903    Client hasn’t set 'SIZE' resource to indicate
  141.                                         awareness of high-level events    
  142.     destPortErr                    -906    Server hasn’t set 'SIZE' resource to indicate
  143.                                         awareness of high-level events, or else is not present    
  144.     sessClosedErr                -917    The kAEDontReconnect flag in the sendMode parameter
  145.                                         was set and the server quit, then restarted    
  146.     errAECoercionFail             -1700    Data could not be coerced to the 
  147.                                         requested Apple event data type    
  148.     errAEWrongDataType            -1703    Wrong Apple event data type    
  149.     errAENotAEDesc                -1704    Not a valid descriptor record    
  150.     errAEBadListItem            -1705    Operation involving a list item failed    
  151.     errAEEventNotHandled        -1708    Event wasn’t handled by an Apple event handler    
  152.     errAEUnknownSendMode        -1710    Invalid sending mode was passed    
  153.     errAEWaitCanceled            -1711    User canceled out of wait loop for reply or receipt    
  154.     errAETimeout                -1712    Apple event timed out    
  155.     errAEUnknownAddressType        -1716    Unknown Apple event address type    
  156.     Any error code returned by the event handler of the target application.
  157.     ____________
  158. */
  159.  
  160. // *****************************************************************************
  161.  
  162. PASCAL OSErr MFEGetItemIcon( const FSSpecPtr fssPtr,
  163.                              const AEIdleUPP idleProcUPP,
  164.                                    Handle     *theIconSuite );
  165.  
  166. /*    
  167.     MFEAddCustomIconToItem adds a custom icon, via the Finder, to the item 
  168.     specified by the fssPtr. 
  169.     If an UPP to an idle function is provided in the idleProcUPP parameter,
  170.     AESend is called with a send mode of kAEWaitReply. If idleProcUPP is set
  171.     to nil, kAENoReply will be used for the send mode.
  172.  
  173.     fssPtr            input:    The item to add the custom icon to.
  174.     theIconSuite    input:    The handle to the icon suite to install.
  175.     iconSelector    input:    An IconSelectorValue specifying which icon types
  176.                             to add.
  177.     idleProcUPP        input:    A UniversalProcPtr for an idle function, or nil.
  178.     
  179.     Result Codes
  180.     _____________
  181.     noErr                        0        No error    
  182.     paramErr                    -50        The value of target or alias parameter, or of both,
  183.                                         is NIL or odd, or the alias record is corrupt
  184.     eLenErr                        -92        Buffer too big to send    
  185.     memFullErr                    -108    Not enough room in heap zone    
  186.     procNotFound                -600    No eligible process with specified descriptor
  187.     connectionInvalid            -609    Nonexistent signature or session ID    
  188.     noUserInteractionAllowed    -610    Background application sends event
  189.                                         requiring authentication    
  190.     noPortErr                    -903    Client hasn’t set 'SIZE' resource to indicate
  191.                                         awareness of high-level events    
  192.     destPortErr                    -906    Server hasn’t set 'SIZE' resource to indicate
  193.                                         awareness of high-level events, or else is not present    
  194.     sessClosedErr                -917    The kAEDontReconnect flag in the sendMode parameter
  195.                                         was set and the server quit, then restarted    
  196.     errAECoercionFail             -1700    Data could not be coerced to the 
  197.                                         requested Apple event data type    
  198.     errAEWrongDataType            -1703    Wrong Apple event data type    
  199.     errAENotAEDesc                -1704    Not a valid descriptor record    
  200.     errAEBadListItem            -1705    Operation involving a list item failed    
  201.     errAEEventNotHandled        -1708    Event wasn’t handled by an Apple event handler    
  202.     errAEUnknownSendMode        -1710    Invalid sending mode was passed    
  203.     errAEWaitCanceled            -1711    User canceled out of wait loop for reply or receipt    
  204.     errAETimeout                -1712    Apple event timed out    
  205.     errAEUnknownAddressType        -1716    Unknown Apple event address type    
  206.     Any error code returned by the event handler of the target application.
  207.     ____________
  208. */
  209.  
  210. // *****************************************************************************
  211. PASCAL OSErr MFEGetEveryItemOnDesktop( const AEIdleUPP idleProcUPP,
  212.                                              AEDescList *objectList );
  213. /*    The MFEGetEveryItemOnDesktop function asks the Finder for a list of object
  214.     descriptors for every item on the desktop (includes files, folders, and
  215.     volumes).
  216.     If an UPP to an idle function is provided in the idleProcUPP parameter,
  217.     AESend is called with a send mode of kAEWaitReply. If idleProcUPP is set
  218.     to nil, kAENoReply will be used for the send mode.
  219.  
  220.     idleProcUPP        input:    A UniversalProcPtr for an idle function, or nil.
  221.     objectList        input:    A null AEDesc.
  222.     iconSelector    output:    A list containing object descriptors,
  223.                             or a null AEDesc if an error is encountered.
  224.     
  225.     Result Codes
  226.     _____________
  227.     noErr                        0        No error
  228.     paramErr                    -50        The value of target or alias parameter, or of both,
  229.                                         is NIL or odd, or the alias record is corrupt
  230.     eLenErr                        -92        Buffer too big to send
  231.     memFullErr                    -108    Not enough room in heap zone
  232.     procNotFound                -600    No eligible process with specified descriptor
  233.     connectionInvalid            -609    Nonexistent signature or session ID
  234.     noUserInteractionAllowed    -610    Background application sends event
  235.                                         requiring authentication
  236.     noPortErr                    -903    Client hasn’t set 'SIZE' resource to indicate
  237.                                         awareness of high-level events
  238.     destPortErr                    -906    Server hasn’t set 'SIZE' resource to indicate
  239.                                         awareness of high-level events, or else is not present
  240.     sessClosedErr                -917    The kAEDontReconnect flag in the sendMode parameter
  241.                                         was set and the server quit, then restarted
  242.     errAECoercionFail             -1700    Data could not be coerced to the
  243.                                         requested Apple event data type    
  244.     errAEWrongDataType            -1703    Wrong Apple event data type    
  245.     errAENotAEDesc                -1704    Not a valid descriptor record
  246.     errAEBadListItem            -1705    Operation involving a list item failed
  247.     errAEEventNotHandled        -1708    Event wasn’t handled by an Apple event handler
  248.     errAEUnknownSendMode        -1710    Invalid sending mode was passed
  249.     errAEWaitCanceled            -1711    User canceled out of wait loop for reply or receipt
  250.     errAETimeout                -1712    Apple event timed out
  251.     errAEUnknownAddressType        -1716    Unknown Apple event address type
  252.     Any error code returned by the event handler of the target application.
  253.     ____________
  254. */
  255.  
  256. // *****************************************************************************
  257.  
  258. PASCAL    OSErr    MFEUpdateItemFSS( const FSSpecPtr fssPtr );
  259. /*
  260.     Given an FSSpec to an item (file, folder, what ever), send an Apple event to
  261.     the Finder asking it to update it's display of the item. For files, shows
  262.     things like icon changes. For folders, shows things like new files that have
  263.     been added.
  264. */
  265.  
  266. // *****************************************************************************
  267.  
  268. PASCAL    OSErr    MFEUpdateItemAlias( const AliasHandle aliasHandle );
  269. /*
  270.     Given an alias to an item (file, folder, what ever), send an Apple event to
  271.     the Finder asking it to update it's display of the item. For files, shows
  272.     things like icon changes. For folders, shows things like new files that have
  273.     been added.
  274. */
  275.  
  276. // *****************************************************************************
  277.  
  278. PASCAL    OSErr MFEOpenFile( const AEIdleUPP idleProcUPP,
  279.                                  FSSpec *fssPtr );
  280. /*
  281.     Given an FSSpec to a file, send an open document event to the
  282.     Finder, passing the FSSpec as the direct parameter.
  283. */
  284.  
  285. #ifdef __cplusplus
  286. }
  287. #endif
  288.  
  289. #ifndef COMPILING_MORE_FINDER_EVENTS
  290. #undef PASCAL
  291. #endif
  292.  
  293.  
  294. #endif//MOREFINDEREVENTS
  295.